//
//  RBTool.h
//  InxparApp
//
//  Created by Riber on 2017/6/9.
//  Copyright © 2017年 Riber. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "AFNetworking.h"

typedef void(^SuccessBlock)(id data);
typedef BOOL(^SuccessSaveBlock)(id data);
typedef void(^FailBlock)(NSError *error, NSInteger status);
typedef void(^CacheBlock)(id data);

@interface RBTool : NSObject

+ (NSURLSessionDataTask *)sendGetWithUrl:(NSString *)url parameters:(NSDictionary *)dict success:(SuccessBlock)successblock fail:(FailBlock)failblock;

+ (NSURLSessionDataTask *)sendGetJsonWithUrl:(NSString *)url parameters:(NSDictionary *)dict success:(SuccessBlock)successblock fail:(FailBlock)failblock;

// get请求 超时时间2秒
+ (NSURLSessionDataTask *)sendGetTimeOutSecondWithUrl:(NSString *)url parameters:(NSDictionary *)dict success:(SuccessBlock)successblock fail:(FailBlock)failblock;

+ (NSURLSessionDataTask *)sendPostWithUrl:(NSString *)url parameters:(NSDictionary *)dict success:(SuccessBlock)successblock fail:(FailBlock)failblock;

+ (NSURLSessionDataTask *)postReturnNoJsonWithUrl:(NSString *)url parameters:(NSDictionary *)dict success:(SuccessBlock)successblock fail:(FailBlock)failblock;

+ (NSURLSessionDataTask *)getReturnNoJsonWithUrl:(NSString *)url parameters:(NSDictionary *)dict success:(SuccessBlock)successblock fail:(FailBlock)failblock;

+ (void)uploadFileWithUrl:(NSString *)url parameters:(NSDictionary *)dict image:(NSData *)image name:(NSString *)name success:(SuccessBlock)successblock fail:(FailBlock)failblock;

//+ (void)sendGetWithUrl:(NSString *)url parameters:(NSDictionary *)dict cacheBlock:(CacheBlock)cacheBlock SuccessSaveBlock:(SuccessSaveBlock)successSaveBlock fail:(FailBlock)failblock;
+ (NSURLSessionDataTask *)sendPostJsonWithUrl:(NSString *)url parameters:(NSDictionary *)dict success:(SuccessBlock)successblock fail:(FailBlock)failblock;


+ (NSString *)getResponseStringWithError:(NSError *)error;

+ (NSString *)convertNull:(id)object;

+ (NSString *)convertReturn:(id)object;

+ (UIColor *)transformColorToUIColor:(NSString *)colorStr;

+ (NSArray *)getSkuStandardsTitleArr:(NSArray *)standards;

+ (NSArray *)getSkuStandardsArr:(NSArray *)standards skuArr:(NSArray *)skus;

+ (NSArray *)getSkusSearchArr:(NSArray *)skus standards:(NSArray *)standards;

+ (NSString *)getSkuStr:(NSDictionary *)skuDict;

+ (NSArray *)convertDictToArr:(NSDictionary *)dict;

+ (NSArray *)convertJsonStringToDict:(NSString *)str;

+ (NSDictionary *)convertJsonString:(NSString *)str;

+ (NSString*)dictionaryToJson:(NSDictionary *)dic;

+ (NSMutableDictionary *)convertNullValueDic:(NSDictionary *)dic;

// 校验手机号
+ (BOOL)checkTelNumber:(NSString*) telNumber;

// 校验密码
+ (BOOL)checkPassword:(NSString*)password;

+ (NSString *)timeFormatted:(NSString *)totalSeconds;

+ (NSString *)timeFormattedToMinute:(NSString *)totalSeconds;

+ (NSString *)timeFormattedGetHour:(NSString *)totalSeconds;

+ (NSString *)timeFormattedGetYear:(NSString *)totalSeconds;

+ (NSString *)timeFormattedWithoutYear:(NSString *)totalSeconds;

// 通过报告id存储图片
+ (BOOL)saveImageToFile:(UIImage *)image reportId:(NSString *)reportId;

// 通过报告id获取存储的图片
+ (UIImage *)getFilePathImageWithReportId:(NSString *)reportId;

// 通过name或version获取app名称或版本号
/**
 * 通过name或version获取app名称或版本号
 * key = name or version
 */
+ (NSString *)getAppNameOrVersion:(NSString *)key;

@end
